package com.dubbo.consumer.controller.order;


import com.alibaba.dubbo.config.annotation.Reference;


import com.dubbo.common.dtos.ResponseResult;
import com.dubbo.model.order.dtos.PageServiceDTO;
import com.dubbo.model.order.dtos.ServiceDTO;
import com.dubbo.model.order.dtos.ServiceOrderDTO;
import com.dubbo.model.order.pojos.ServiceOrder;
import com.dubbo.order.ServiceOrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/service")
public class ServiceOrderController {

    @Reference(check = false)
    private ServiceOrderService orderService;

    /**
     * 页面展示
     * @return
     */
    @GetMapping("/paretsOrderList")
    public ResponseResult<List<ServiceOrder>> paretsOrderList(PageServiceDTO dto){
        return orderService.paretsOrderList(dto);
    }

    /**
     * 根据id查数据
     * @param id
     * @return
     */
    @GetMapping("findById/{id}")
    public ResponseResult<ServiceDTO> findById(@PathVariable Long id){
        return orderService.findById(id);
    }

    /**
     * 分页查询
     * @param dto：
     * @return
     */
    @GetMapping("/selectByPage")
    public ResponseResult<List<ServiceOrder>> selectByPage(ServiceOrderDTO dto){
        return orderService.selectByPage(dto);
    }

    /**
     * 关闭未服务订单
     * @param id
     * @return
     */
    @GetMapping("/closeOrder/{id}")
    public ResponseResult closeOrder(@PathVariable Long id){
        return orderService.closeOrder(id);
    }
}
